import { Token } from '@/interface/token'
// token
const Token_Key = 'zg_token'

// 获取token
export const getToken = (): Token => {
  return JSON.parse(localStorage.getItem(Token_Key) || '{}')
}

// 设置token
export const setToken = (token: Token) => {
  return localStorage.setItem(Token_Key, JSON.stringify(token))
}

// 删除token
export const removeToken = () => {
  return localStorage.removeItem(Token_Key)
}

// 判断是否有
export const hasToken = () => {
  return !!getToken().token
}
